﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Networking
{
    /// <summary>
    /// Interaction logic for ChatServer.xaml
    /// </summary>
    public partial class ChatServer : UserControl
    {
        Server server;
        public ChatServer()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(ChatServer_Loaded);
        }

        void ChatServer_Loaded(object sender, RoutedEventArgs e)
        {
            server = new Server("0.0.0.0", 25000);
            server.Received += new ImageReceivedEventHandler(server_Received);
        }

        void server_Received(object sender, ImageReceivedEventArgs e)
        {
            image1.Source = e.ReceivedBitmap.ToBitmapSource();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            server.Begin();
        }
    }
}
